import time
from zentao_pms.base.base_get import Tools


class adduser_tool(Tools):
    adduser_url = "http://192.168.0.125:7007/www/index.php?m=user&f=login&referer=L3d3dy8="
    organization = '[id = "menucompany"]'
    adduser_button = '[id="submenuaddUser"]'
    username = '[id="account"]'  # 定位用户名
    name = '[id="realname"]'  # 定位真实姓名
    p_word = '[id="password1"]'  # 定位密码
    pp_word = '[id="password2"]'  # 定位请重复密码
    admin_word = '[id="verifyPassword"]'  # 定位输入管理员密码
    save_button = '[id="submit"]'  # 定位保存按钮
    add_success_ele = '[onclick="manageContacts()"]'  # 保存成功断言  我的查询

    def adduser_action(self, username, name, p_word, pp_word, admin_word):
        self.visit(self.adduser_url)
        self.by_css(self.organization).click()
        time.sleep(1)
        self.by_css(self.adduser_button).click()
        time.sleep(1)
        self.by_css(self.username).send_keys(username)
        time.sleep(1)
        self.by_css(self.name).send_keys(name)
        time.sleep(1)
        self.by_css(self.p_word).send_keys(p_word)
        time.sleep(1)
        self.by_css(self.pp_word).send_keys(pp_word)
        time.sleep(1)
        self.by_css(self.admin_word).send_keys(admin_word)
        time.sleep(1)
        self.by_css(self.save_button).click()
        time.sleep(1)

    def get_success_msg(self):
        return self.by_css(self.add_success_ele).text